home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qvalidator.h.z / qvalidator.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  2.2 KB  |  92 lines

  1. /****************************************************************************
  2. ** $Id: qvalidator.h,v 2.11 1998/07/03 00:09:54 hanord Exp $
  3. **
  4. ** Definition of validator classes.
  5. **
  6. ** Created : 970610
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QVALIDATOR_H
  25. #define QVALIDATOR_H
  26.  
  27. #ifndef QT_H
  28. #include "qobject.h"
  29. #include "qstring.h"
  30. #endif // QT_H
  31.  
  32.  
  33. class QValidator: public QObject
  34. {
  35.     Q_OBJECT
  36. public:
  37.     QValidator( QWidget * parent, const char * name = 0 );
  38.     ~QValidator();
  39.  
  40.     enum State { Invalid, Valid, Acceptable };
  41.  
  42.     virtual State validate( QString &, int & ) = 0;
  43.     virtual void fixup( QString & );
  44. };
  45.  
  46.  
  47. class QIntValidator: public QValidator
  48. {
  49.     Q_OBJECT
  50. public:
  51.     QIntValidator( QWidget * parent, const char * name = 0 );
  52.     QIntValidator( int bottom, int top,
  53.            QWidget * parent, const char * name = 0 );
  54.     ~QIntValidator();
  55.  
  56.     QValidator::State validate( QString &, int & );
  57.  
  58.     virtual void setRange( int bottom, int top );
  59.  
  60.     int bottom() const { return b; }
  61.     int top() const { return t; }
  62.     
  63. private:
  64.     int b, t;
  65. };
  66.  
  67.  
  68. class QDoubleValidator: public QValidator
  69. {
  70.     Q_OBJECT
  71. public:
  72.     QDoubleValidator( QWidget * parent, const char * name = 0 );
  73.     QDoubleValidator( double bottom, double top, int decimals,
  74.               QWidget * parent, const char * name = 0 );
  75.     ~QDoubleValidator();
  76.  
  77.     QValidator::State validate( QString &, int & );
  78.  
  79.     virtual void setRange( double bottom, double top, int decimals = 0 );
  80.  
  81.     double bottom() const { return b; }
  82.     double top() const { return t; }
  83.     int decimals() const { return d; }
  84.     
  85. private:
  86.     double b, t;
  87.     int d;
  88. };
  89.  
  90.  
  91. #endif // QVALIDATOR_H
  92.